package com.homework.service;

import java.sql.SQLException;

import com.homework.bean.AnswerBean;
import com.homework.bean.CourseBean;
import com.homework.bean.PageInfoBean;
import com.homework.bean.QuestionBean;
import com.homework.bean.UserAnswerListBean;
import com.homework.bean.UserBean;
import com.homework.bean.UserQuestionBean;
import com.homework.bean.UserQuestionListBean;
import com.homework.dao.QuestionDao;

public class QuestionService {

	private static QuestionService questionService = null;
	private QuestionDao questionDao;

	public QuestionService() {
		this.questionDao = QuestionDao.getInstance();
	}

	public static QuestionService getInstance() {
		if (questionService == null) {
			questionService = new QuestionService();
		}
		return questionService;
	}

	// 问题列表
	public UserQuestionListBean questionShow(CourseBean courseBean,
			PageInfoBean pageInfoBean) throws SQLException {
		return questionDao.questionShow(courseBean, pageInfoBean);
	}
	
	//添加问题
	public void questionAdd(UserBean userBean,CourseBean courseBean,
			QuestionBean questionBean){
		questionDao.questionAdd(userBean, courseBean,questionBean);
	}
	
	// 获取问题
	public UserQuestionBean userQuestionGet(QuestionBean questionBean) throws SQLException{
		return questionDao.userQuestionGet(questionBean);
	}
	
	// 获取回复
	public UserAnswerListBean userAnswerListGet(QuestionBean questionBean,PageInfoBean pageInfoBean) throws SQLException{
		return questionDao.userAnswerListGet(questionBean,pageInfoBean);
	}			
	
	// 提交回复
	public void answerAdd(UserBean userBean,CourseBean courseBean,AnswerBean answerBean){
		questionDao.answerAdd(userBean, courseBean,answerBean);
	}
}
